﻿<?php

/**
 * @author Nguyen Xuan Hong
 * @copyright 2010
 */
require_once("includes/album.tbl.php");
require_once("includes/picture.tbl.php");
require_once("viewinfo.php");

$branch_id = $_REQUEST["branch"];
if($branch_id >= 0)
{
	$album_id = $_REQUEST["album"];
	
	if(!($album_id > 0))
	{
		$pClsAlbum = new clsAlbumTable();
		$listalbum = $pClsAlbum->listobj($branch_id);
		if(count($listalbum) > 1)
		{
			$title = "Thư viện Album ảnh của bé";
			view_list_album($title, $listalbum, $branch_id);		
		}
		else
		{
			if(count($listalbum) > 0)
			{
				$pClsAlbum = current($listalbum);
				$album_id = $pClsAlbum->value('id');
			}
		}
		
	}
	
	if($album_id > 0)
	{
		$pClsAlbum = new clsAlbumTable($album_id);
		$title = $pClsAlbum->value("title");
		
		$pClsPicture = new clsPictureTable();
		$listpicture = $pClsPicture->listobj($album_id);
		view_album($title, $listpicture, $branch_id);
		
		$pClsAlbum = new clsAlbumTable();
		$listalbum = $pClsAlbum->listobj($branch_id);
		if(count($listalbum) > 1)
		{
			$title = "Các album ảnh khác";
			view_list_album($title, $listalbum, $branch_id);		
		}
	//	require_once("viewalbum.php");		
	}
}
else
{
	$pClsAlbum = new clsAlbumTable();
	$listalbum = $pClsAlbum->listobj();
	if(count($listalbum) > 1)
	{
		$title = "Thư viện Album ảnh của bé";
		view_list_album($title, $listalbum, $branch_id);		
	}
}
?>